<template>
    <div class="filter">
        <div class="filter-item">
            <el-select
                v-model="depId"
                class="m-2"
                placeholder="请选择所属单位"
                style="width: 145px"
                :disabled="localTypeUnit != '1'"
            >
                <el-option
                    v-for="item in depIdList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                />
            </el-select>
        </div>
        <div class="uploadBtn filter-item">
            <el-select
                v-model="uploadType"
                class="m-2"
                placeholder="请选择上传类型"
                style="width: 160px"
            >
                <el-option
                    v-for="item in uploadTypeList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                />
            </el-select>
        </div>

        <div class="uploadBtn filter-item">
            <el-date-picker
                v-model="dateTime"
                type="date"
                placeholder="请选择上传时间"
            />
        </div>
        <div class="uploadBtn filter-item">
            <el-input
                v-model="username"
                placeholder="请输入提交人"
                style="width: 145px"
            />
        </div>
        <div class="uploadBtn filter-item">
            <el-select
                v-model="auditStatus"
                class="m-2"
                placeholder="请选择状态"
                style="width: 160px"
            >
                <el-option
                    v-for="item in auditStatusList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                />
            </el-select>
        </div>

        <div class="uploadBtn filter-item">
            <el-button
                type="primary"
                @click="queryAudit"
            >查询</el-button>
            <el-button
                type="primary"
                @click="reset"
            >重置</el-button>
            <el-button
                type="danger"
                v-if="isAdmin"
                @click="deleteBatch"
            >批量删除</el-button>
        </div>
    </div>
    <el-table
        :data="tableData"
        border
        @selection-change="handleSelectionChange"
    >
        <el-table-column
            type="selection"
            width="55"
            align="center"
        />
        <el-table-column
            type="index"
            label="序号"
            width="60"
            align="center"
        />
        <el-table-column
            prop="dataType"
            label="提交类型"
            align="center"
        >
            <template #default="scope">
                {{ scope.row.dataType == 1 ? "手工录入" : "文件上传" }}
            </template>
        </el-table-column>
        <el-table-column
            prop="createTime"
            label="提交时间"
            align="center"
        />
        <el-table-column
            prop="username"
            label="提交人"
            align="center"
        />
        <el-table-column
            prop="auditType"
            label="数据类型"
            align="center"
        >
            <template #default="scope">
                {{
                    scope.row.auditType == 1
                        ? "生产数据"
                        : scope.row.auditType == 2
                        ? "化验数据"
                        : "工艺数据"
                }}
            </template>
        </el-table-column>
        <el-table-column
            prop="address"
            label="详情"
            align="center"
            width="300"
        >
            <template #default="scope">
                <div style="
                        display: flex;
                        flex-direction: row;
                        justify-content: center;
                        align-items: center;
                    ">
                    <div
                        class="preview"
                        v-if="scope.row.dataType == 2"
                    >
                        <div class="name">
                            <img
                                src="../charts/excelIcon.jpg"
                                alt=""
                            />
                            {{ scope.row.fileName }}
                        </div>
                        <!-- <div style="margin: 0 6px;"> | </div> -->
                        <div class="name">
                            <el-button
                                size="small"
                                @click="preview(scope.$index, scope.row)"
                            >预览</el-button>
                        </div>
                    </div>
                    <div
                        style="margin-right: 6px"
                        v-else
                    >
                        <el-button
                            size="small"
                            @click="queryWaterDetail(scope.row)"
                        >详情</el-button>
                    </div>
                    <div>
                        <el-popover
                            :visible="visible"
                            placement="bottom"
                            :width="360"
                            :trigger="'hover'"
                        >
                            <el-scrollbar style="max-height: 300px">
                                <p><strong>校验提示:</strong></p>
                                <div
                                    style="line-height: 1.5"
                                    v-html="
                                        scope.row.errMsg
                                            ? scope.row.errMsg.replace(
                                                  /\n/g,
                                                  '<br/>'
                                              )
                                            : ''
                                    "
                                ></div>
                            </el-scrollbar>
                            <template #reference>
                                <div
                                    class="name"
                                    v-if="scope.row.errMsg"
                                >
                                    <el-button
                                        type="warning"
                                        size="small"
                                    >校验提示</el-button>
                                </div>
                            </template>
                        </el-popover>
                    </div>
                </div>
            </template>
        </el-table-column>
        <el-table-column
            prop="address"
            label="审核"
            align="center"
            width="150"
            v-if="isAdmin"
        >
            <template #default="scope">
                <div
                    v-if="scope.row.auditStatus != '0'"
                    style="color: #ccc; font-size: 12px"
                >
                    {{
                        scope.row.auditStatus == "-1"
                            ? "审核不通过"
                            : scope.row.auditStatus == "1"
                            ? "审核通过"
                            : "待审核"
                    }}
                </div>
                <!-- <el-button v-if="scope.row.auditStatus == '-1'" size="small" type="">审核不通过</el-button>
                <el-button v-if="scope.row.auditStatus == '1'" size="small" type="">审核通过</el-button> -->
                <el-button
                    v-if="scope.row.auditStatus == '0'"
                    size="small"
                    type="primary"
                    @click="auditData(scope.row, '1')"
                >通过</el-button>
                <el-button
                    v-if="scope.row.auditStatus == '0'"
                    size="small"
                    type="warning"
                    @click="auditData(scope.row, '-1')"
                >不通过</el-button>
            </template>
        </el-table-column>
        <el-table-column
            prop="address"
            label="操作"
            align="center"
            v-if="isAdmin"
        >
            <template #default="scope">
                <el-button
                    size="small"
                    type="danger"
                    @click="deleteData(scope.row)"
                >删除</el-button>
            </template>
        </el-table-column>
    </el-table>

    <el-pagination
        v-model:current-page="pageNo"
        v-model:page-size="pageSize"
        layout="total, prev, pager, next, jumper"
        :total="total"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        class="paginationStyle"
    />
    <el-dialog
        v-model="dialogTableVisible"
        title="文件预览"
        width="80%"
    >
        <el-scrollbar class="containRouter">
            <div
                style="height: 500px"
                id="tableau"
                v-html="tableau"
            ></div>
        </el-scrollbar>
    </el-dialog>
    <el-dialog
        v-model="detailVisible"
        title="录入详情"
        width="80%"
    >
        <el-scrollbar class="containRouter">
            <el-table
                :data="detailTableData"
                v-if="dialogDetailType == '1'"
            >
                <el-table-column
                    prop="entryDate"
                    label="日期"
                    width="130"
                />
                <el-table-column
                    prop="treatedWaterQuantity"
                    label="处理水量(万吨)"
                />
                <el-table-column
                    prop="waterContent"
                    label="中水量(吨)"
                />
                <el-table-column
                    prop="overflowsSewage"
                    label="外溢雨污水量(万吨)"
                />
                <el-table-column
                    prop="ch3cooNa"
                    label="乙酸钠(吨)"
                />
                <el-table-column
                    prop="na2C2O4"
                    label="复合碳源(吨)"
                />
                <el-table-column
                    prop="pac"
                    label="PAC(吨)"
                />
            </el-table>
            <el-table
                :data="detailTableData"
                v-if="dialogDetailType == '2'"
            >
                <el-table-column
                    prop="date"
                    label="日期"
                    width="130"
                    fixed=""
                />
                <el-table-column
                    prop="treatedWaterQuantity"
                    label="处理水量"
                    width="100"
                />
                <el-table-column
                    prop="overflowsSewage"
                    label="外溢雨污水量"
                    v-if="currentType == '2'"
                />
                <el-table-column
                    prop="waterTemperature"
                    label="水温"
                />
                <el-table-column label="pH">
                    <el-table-column
                        prop="phIn"
                        label="进水"
                    />
                    <el-table-column
                        prop="phOut"
                        label="出水"
                    />
                </el-table-column>
                <el-table-column label="SS(mg/L)">
                    <el-table-column
                        prop="ssIn"
                        label="进水"
                    />
                    <el-table-column
                        prop="ssOut"
                        label="出水"
                    />
                </el-table-column>
                <el-table-column label="COD(mg/L)">
                    <el-table-column
                        prop="codIn"
                        label="进水"
                    />
                    <el-table-column
                        prop="codOut"
                        label="出水"
                    />
                </el-table-column>
                <el-table-column label="BOD₃(mg/L)">
                    <el-table-column
                        prop="bodIn"
                        label="进水"
                    />
                    <el-table-column
                        prop="bodOut"
                        label="出水"
                    />
                </el-table-column>
                <el-table-column label="TN(mg/L)">
                    <el-table-column
                        prop="tnIn"
                        label="进水"
                    />
                    <el-table-column
                        prop="tnOut"
                        label="出水"
                    />
                </el-table-column>
                <el-table-column label="NH₃-H(mg/L)">
                    <el-table-column
                        prop="nhNIn"
                        label="进水"
                    />
                    <el-table-column
                        prop="nhNOut"
                        label="出水"
                    />
                </el-table-column>
                <el-table-column label="TP(mg/L)">
                    <el-table-column
                        prop="tpIn"
                        label="进水"
                    />
                    <el-table-column
                        prop="tpOut"
                        label="出水"
                    />
                </el-table-column>
                <el-table-column
                    prop="cufOut"
                    label="粪大肠菌群(个/L)"
                    width="100"
                />
                <el-table-column
                    prop="chroma"
                    label="色度"
                    width="100"
                />
            </el-table>
            <el-table
                :data="detailTableData"
                v-if="dialogDetailType == '3' && currentType == '2'"
            >
                <el-table-column
                    prop="date"
                    label="日期"
                    width="130"
                    fixed
                />
                <el-table-column label="DO(mg/L)">
                    <el-table-column
                        prop="do1"
                        label="氧化沟东"
                    />
                    <el-table-column
                        prop="do2"
                        label="氧化沟西"
                    />
                    <el-table-column
                        prop="do3"
                        label="cass"
                    />
                    <el-table-column
                        prop="do4"
                        label="A2/O东"
                    />
                    <el-table-column
                        prop="do5"
                        label="A2/O西"
                    />
                    <el-table-column
                        prop="do6"
                        label="四期南沟"
                    />
                    <el-table-column
                        prop="do7"
                        label="四期北沟"
                    />
                </el-table-column>
                <el-table-column label="MLSS(mg/L)">
                    <el-table-column
                        prop="mlss1"
                        label="氧化沟东"
                    />
                    <el-table-column
                        prop="mlss2"
                        label="氧化沟西"
                    />
                    <el-table-column
                        prop="mlss3"
                        label="cass"
                    />
                    <el-table-column
                        prop="mlss4"
                        label="A2/O东"
                    />
                    <el-table-column
                        prop="mlss5"
                        label="A2/O西"
                    />
                    <el-table-column
                        prop="mlss6"
                        label="四期南沟"
                    />
                    <el-table-column
                        prop="mlss7"
                        label="四期北沟"
                    />
                </el-table-column>
                <el-table-column label="SV30（%）">
                    <el-table-column
                        prop="sv1"
                        label="氧化沟东"
                    />
                    <el-table-column
                        prop="sv2"
                        label="氧化沟西"
                    />
                    <el-table-column
                        prop="sv3"
                        label="cass"
                    />
                    <el-table-column
                        prop="sv4"
                        label="A2/O东"
                    />
                    <el-table-column
                        prop="sv5"
                        label="A2/O西"
                    />
                    <el-table-column
                        prop="sv6"
                        label="四期南沟"
                    />
                    <el-table-column
                        prop="sv7"
                        label="四期北沟"
                    />
                </el-table-column>
                <el-table-column label="SVI">
                    <el-table-column
                        prop="svi1"
                        label="氧化沟东"
                    />
                    <el-table-column
                        prop="svi2"
                        label="氧化沟西"
                    />
                    <el-table-column
                        prop="svi3"
                        label="cass"
                    />
                    <el-table-column
                        prop="svi4"
                        label="A2/O东"
                    />
                    <el-table-column
                        prop="svi5"
                        label="A2/O西"
                    />
                    <el-table-column
                        prop="svi6"
                        label="四期南沟"
                    />
                    <el-table-column
                        prop="svi7"
                        label="四期北沟"
                    />
                </el-table-column>
                <el-table-column label="MLVSS(mg/L)">
                    <el-table-column
                        prop="mlvss1"
                        label="氧化沟东"
                    />
                    <el-table-column
                        prop="mlvss2"
                        label="氧化沟西"
                    />
                    <el-table-column
                        prop="mlvss3"
                        label="cass"
                    />
                    <el-table-column
                        prop="mlvss4"
                        label="A2/O东"
                    />
                    <el-table-column
                        prop="mlvss5"
                        label="A2/O西"
                    />
                    <el-table-column
                        prop="mlvss6"
                        label="四期南沟"
                    />
                    <el-table-column
                        prop="mlvss7"
                        label="四期北沟"
                    />
                </el-table-column>
                <el-table-column label="污泥含水率（%）">
                    <el-table-column
                        prop="containWater1"
                        label="北厂区污泥脱水间"
                    />
                    <el-table-column
                        prop="containWater2"
                        label="南厂区污泥脱水间"
                    />
                    <el-table-column
                        prop="containWater3"
                        label="四期脱水间"
                    />
                </el-table-column>
            </el-table>
            <el-table
                :data="detailTableData"
                v-if="dialogDetailType == '3' && currentType == '4'"
            >
                <el-table-column
                    prop="date"
                    label="日期"
                    width="130"
                    fixed
                />
                <el-table-column label="DO(mg/L)">
                    <el-table-column
                        prop="do1"
                        label="1#氧化沟"
                    />
                    <el-table-column
                        prop="do2"
                        label="2#氧化沟"
                    />
                    <el-table-column
                        prop="do3"
                        label="3#氧化沟"
                    />
                    <el-table-column
                        prop="do4"
                        label="4#氧化沟"
                    />
                    <el-table-column
                        prop="do5"
                        label="5#氧化沟"
                    />
                </el-table-column>
                <el-table-column label="MLSS(mg/L)">
                    <el-table-column
                        prop="mlss1"
                        label="1#氧化沟"
                    />
                    <el-table-column
                        prop="mlss2"
                        label="2#氧化沟"
                    />
                    <el-table-column
                        prop="mlss3"
                        label="3#氧化沟"
                    />
                    <el-table-column
                        prop="mlss4"
                        label="4#氧化沟"
                    />
                    <el-table-column
                        prop="mlss5"
                        label="5#氧化沟"
                    />
                </el-table-column>
                <el-table-column label="SV30（%）">
                    <el-table-column
                        prop="sv1"
                        label="1#氧化沟"
                    />
                    <el-table-column
                        prop="sv2"
                        label="2#氧化沟"
                    />
                    <el-table-column
                        prop="sv3"
                        label="3#氧化沟"
                    />
                    <el-table-column
                        prop="sv4"
                        label="4#氧化沟"
                    />
                    <el-table-column
                        prop="sv5"
                        label="5#氧化沟"
                    />
                </el-table-column>
                <el-table-column label="SVI">
                    <el-table-column
                        prop="svi1"
                        label="1#氧化沟"
                    />
                    <el-table-column
                        prop="svi2"
                        label="2#氧化沟"
                    />
                    <el-table-column
                        prop="svi3"
                        label="3#氧化沟"
                    />
                    <el-table-column
                        prop="svi4"
                        label="4#氧化沟"
                    />
                    <el-table-column
                        prop="svi5"
                        label="5#氧化沟"
                    />
                </el-table-column>
                <el-table-column label="MLVSS(mg/L)">
                    <el-table-column
                        prop="mlvss1"
                        label="1#氧化沟"
                    />
                    <el-table-column
                        prop="mlvss2"
                        label="2#氧化沟"
                    />
                    <el-table-column
                        prop="mlvss3"
                        label="3#氧化沟"
                    />
                    <el-table-column
                        prop="mlvss4"
                        label="4#氧化沟"
                    />
                    <el-table-column
                        prop="mlvss5"
                        label="5#氧化沟"
                    />
                </el-table-column>
                <el-table-column label="污泥含水率（%）">
                    <el-table-column
                        prop="containWater1"
                        label="二期板框"
                        width="140"
                    />
                </el-table-column>
            </el-table>
            <el-table
                :data="detailTableData"
                v-if="dialogDetailType == '3' && currentType == '5'"
            >
                <el-table-column
                    prop="date"
                    label="日期"
                    width="130"
                    fixed
                />
                <el-table-column label="DO(mg/L)">
                    <el-table-column
                        prop="do1"
                        label="1#沟"
                    />
                    <el-table-column
                        prop="do2"
                        label="2#沟"
                    />
                    <el-table-column
                        prop="do3"
                        label="3#沟"
                    />
                    <el-table-column
                        prop="do4"
                        label="4#沟"
                    />
                </el-table-column>
                <el-table-column label="MLSS(mg/L)">
                    <el-table-column
                        prop="mlss1"
                        label="1#沟"
                    />
                    <el-table-column
                        prop="mlss2"
                        label="2#沟"
                    />
                    <el-table-column
                        prop="mlss3"
                        label="3#沟"
                    />
                    <el-table-column
                        prop="mlss4"
                        label="4#沟"
                    />
                </el-table-column>
                <el-table-column label="SV30（%）">
                    <el-table-column
                        prop="sv1"
                        label="1#沟"
                    />
                    <el-table-column
                        prop="sv2"
                        label="2#沟"
                    />
                    <el-table-column
                        prop="sv3"
                        label="3#沟"
                    />
                    <el-table-column
                        prop="sv4"
                        label="4#沟"
                    />
                </el-table-column>
                <el-table-column label="SVI">
                    <el-table-column
                        prop="svi1"
                        label="1#沟"
                    />
                    <el-table-column
                        prop="svi2"
                        label="2#沟"
                    />
                    <el-table-column
                        prop="svi3"
                        label="3#沟"
                    />
                    <el-table-column
                        prop="svi4"
                        label="4#沟"
                    />
                </el-table-column>
                <el-table-column label="MLVSS(mg/L)">
                    <el-table-column
                        prop="mlvss1"
                        label="1#沟"
                    />
                    <el-table-column
                        prop="mlvss2"
                        label="2#沟"
                    />
                    <el-table-column
                        prop="mlvss3"
                        label="3#沟"
                    />
                    <el-table-column
                        prop="mlvss4"
                        label="4#沟"
                    />
                </el-table-column>
                <el-table-column label="污泥含水率（%）">
                    <el-table-column
                        prop="containWater1"
                        label="板框压滤"
                        width="140"
                    />
                </el-table-column>
            </el-table>
            <el-table
                :data="detailTableData"
                v-if="dialogDetailType == '3' && currentType == '3'"
            >
                <el-table-column
                    prop="date"
                    label="日期"
                    width="130"
                    fixed
                />
                <el-table-column label="DO(mg/L)">
                    <el-table-column
                        prop="do1"
                        label="南"
                    />
                    <el-table-column
                        prop="do2"
                        label="北"
                    />
                </el-table-column>
                <el-table-column label="MLSS(mg/L)">
                    <el-table-column
                        prop="mlss1"
                        label="南"
                    />
                    <el-table-column
                        prop="mlss2"
                        label="北"
                    />
                </el-table-column>
                <el-table-column label="SV30（%）">
                    <el-table-column
                        prop="sv1"
                        label="南"
                    />
                    <el-table-column
                        prop="sv2"
                        label="北"
                    />
                </el-table-column>
                <el-table-column label="SVI">
                    <el-table-column
                        prop="svi1"
                        label="南"
                    />
                    <el-table-column
                        prop="svi2"
                        label="北"
                    />
                </el-table-column>
                <el-table-column label="MLVSS(mg/L)">
                    <el-table-column
                        prop="mlvss1"
                        label="南"
                    />
                    <el-table-column
                        prop="mlvss2"
                        label="北"
                    />
                </el-table-column>
                <el-table-column
                    label="污泥含水率（%）"
                    prop="containWater1"
                    width="140"
                >
                    <!-- <el-table-column prop="containWater1" label="北厂区污泥脱水间" />
          <el-table-column prop="containWater1" label="南厂区污泥脱水间" />
          <el-table-column prop="containWater1" label="四期脱水间" /> -->
                </el-table-column>
            </el-table>
        </el-scrollbar>
    </el-dialog>
</template>

<script setup>
import dataListHttp from "@/https/dataList";
import Storage from "@/utils/storage.js"; // storage工具类，简单的封装
import axios from "axios";
import { ElMessage, ElMessageBox } from "element-plus";
import moment from "moment";
import { onMounted, ref } from "vue";
import * as XLSX from "xlsx";

const depId = ref("");
const uploadType = ref("");
const currentType = ref("");
const pageNo = ref(1);
const pageSize = ref(10);
const total = ref(0);
const uploadTypeList = ref([
    { label: "文件上传", value: "2" },
    { label: "手工录入", value: "1" },
]);
const depIdList = ref([
    { label: "全部", value: "1" },
    { label: "星沙厂", value: "2" },
    { label: "城西厂", value: "3" },
    { label: "城北厂", value: "4" },
    { label: "城南厂", value: "5" },
    { label: "城东厂", value: "6" },
]);

const localTypeUnit = ref(Storage.localGet("depId"));
depId.value = localTypeUnit.value;

const roleIds = ref(Storage.localGet("roleIds"));
const isAdmin = ref(false);
isAdmin.value = roleIds.value.includes(1);
console.log(isAdmin.value, "isAdmin.value");
const dialogDetailType = ref("");
const dateTime = ref("");
const username = ref("");
const auditStatus = ref("");
const auditStatusList = ref([
    { label: "未审核", value: "0" },
    { label: "审核未通过", value: "-1" },
    { label: "审核通过", value: "1" },
]);

let tableData = ref([]);
let detailTableData = ref([]);
let tableau = ref(null);
let dialogTableVisible = ref(false);
let detailVisible = ref(false);
function preview (index, row) {
    if (["xls", "xlsx"].includes("xls")) {
        dialogTableVisible.value = true;
        axios
            // .get(`waterFile/${row.fileName}`, {
            .get(`${row.filePath}`, {
                responseType: "arraybuffer", // 设置响应体类型为arraybuffer
            })
            .then(({ data }) => {
                let workbook = XLSX.read(new Uint8Array(data), {
                    type: "array",
                }); // 解析数据
                var worksheet = workbook.Sheets[workbook.SheetNames[0]]; // workbook.SheetNames 下存的是该文件每个工作表名字,这里取出第一个工作表
                tableau.value = XLSX.utils.sheet_to_html(worksheet); // 渲染
            });
        return;
    }
}
onMounted(() => {
    queryAudit();
});
const reset = () => {
    uploadType.value = "";
    dateTime.value = "";
    username.value = "";
    auditStatus.value = "";
    queryAudit();
};
const auditData = (row, auditStatus) => {
    let auditStatusName = auditStatus == "-1" ? "不通过审核" : "通过审核";
    ElMessageBox.alert(`确认${auditStatusName}吗？`, "审核", {
        // if you want to disable its autofocus
        // autofocus: false,
        confirmButtonText: "确认",
        callback: (action) => {
            if (action == "confirm") {
                let params = {
                    auditStatus: auditStatus,
                    id: row.id,
                };
                dataListHttp.auditData(params).then((res) => {
                    if (res.data.code == 200) {
                        queryAudit();
                    }
                });
            }
        },
    });
};
const deleteData = (row) => {
    ElMessageBox.confirm(`是否删除该数据？`, "删除", {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: "warning",
    })
        .then(() => {
            dataListHttp.auditRemove(row).then((res) => {
                console.log(res);
                if (res.data.code == 200) {
                    ElMessage({
                        message: "删除成功",
                        type: "success",
                    });
                    queryAudit();
                } else {
                    ElMessage({
                        message: "删除失败！",
                        type: "error",
                    });
                }
            });
        })
        .catch(() => {
            ElMessage({
                type: "info",
                message: "取消删除",
            });
        });
};
let rowDataList = ref([]);
const handleSelectionChange = (rowData) => {
    console.log(rowData);
    rowDataList.value = rowData;
};
const deleteBatch = () => {
    if (rowDataList.value.length > 0) {
        ElMessageBox.confirm(`是否删除选中数据？`, "删除", {
            confirmButtonText: "确认",
            cancelButtonText: "取消",
            type: "warning",
        })
            .then(() => {
                let ids = [];
                rowDataList.value.forEach((item) => {
                    ids.push(item.id);
                });
                dataListHttp.auditBatchRemove({ ids: ids }).then((res) => {
                    console.log(res);
                    if (res.data.code == 200) {
                        ElMessage({
                            message: "删除成功",
                            type: "success",
                        });
                        queryAudit();
                    } else {
                        ElMessage({
                            message: "删除失败！",
                            type: "error",
                        });
                    }
                });
            })
            .catch(() => {
                ElMessage({
                    type: "info",
                    message: "取消删除",
                });
            });
    } else {
        ElMessage({
            type: "warning",
            message: "请至少勾选一条数据！",
        });
    }
};
const handleSizeChange = (val) => {
    pageSize.value = val;
    queryAudit();
};
const handleCurrentChange = (val) => {
    pageNo.value = val;
    queryAudit();
};
const queryAudit = () => {
    let params = {
        auditStatus: auditStatus.value,
        dataType: uploadType.value,
        username: username.value,
        depId: depId.value,
        startTime: dateTime.value
            ? moment(dateTime.value).format("YYYY-MM-DD")
            : "",
        pageSize: pageSize.value,
        pageNo: pageNo.value,
    };
    dataListHttp.queryAudit(params).then((res) => {
        console.log(res);
        tableData.value = res.data.data.records;
        total.value = res.data.data.total;
    });
};
const queryWaterDetail = (row) => {
    detailVisible.value = true;
    currentType.value = row.depId;
    console.log(currentType.value);
    let http =
        row.auditType == "1"
            ? "queryWaterDetail"
            : row.auditType == "2"
                ? "queryAssayDetail"
                : "queryCraftDetail";
    dialogDetailType.value = row.auditType;
    dataListHttp[http](row.id).then((res) => {
        console.log(res.data.data);
        res.data.data.forEach((item) => {
            item.entryDate = moment(item.entryDate).format("YYYY-MM-DD");
        });
        detailTableData.value = res.data.data;
    });
};
</script>

<style lang="less">
.preview {
    display: flex;
    flex-direction: row;
    align-items: center;

    .name {
        font-size: 12px;
        display: flex;
        flex-direction: row;
        align-items: center;
        margin: 0 6px;

        img {
            width: 14px;
            height: 14px;
            margin-right: 2px;
        }
    }
}

.el-dialog__header {
    border-bottom: 1px solid #ccc;
    margin-right: 0;
}

.el-dialog__body {
    padding: 30px;
}
.filter {
    display: flex;
    flex-direction: row;
}

.uploadBtn {
    text-align: left;
    margin-bottom: 40rem;
    margin-right: 20rem;
}

#tableau table {
    width: 100%;

    #sjs-A1 {
        width: 100%;
        text-align: center;
        line-height: 2;
        color: #333;
        font-size: 16px;
        font-weight: bold;
        margin-bottom: 20px;
    }

    td {
        border: 1px solid #ccc;
        text-align: center;
        line-height: 1.5;
    }
}
</style>
